﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;

namespace WebSite.cn
{
    public partial class hotpro : System.Web.UI.Page
    {
        // Fields
        public StringBuilder hotmsg3 = new StringBuilder();
    
        public string sPriceName = "";
 
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["backHref"] = Request.Url.PathAndQuery;
            if (!IsPostBack)
            {
                this.Bind();
            }
        }

        protected void Bind()
        {
            string sql = "SELECT proid,proname,proprice1,proprice3,proprice4,propic2,typeid,instruction FROM DB_Shoppro where visible=1 and proisshow=1 and languages=1 and isnull(proku1,0)>0 ";
            if (base.Request.QueryString["sid"] != null)
            {
                if (re.replace(base.Request.QueryString["sid"]) == "1")
                {
                    sql = sql + " and proisnew1=1";
                }
                if (re.replace(base.Request.QueryString["sid"]) == "2")
                {
                    sql = sql + " and proisnew2=1";
                }
                if (re.replace(base.Request.QueryString["sid"]) == "3")
                {
                    sql = sql + " and proisnew3=1";
                }
                if (re.replace(base.Request.QueryString["sid"]) == "4")
                {
                    sql = sql + " and proisnew4=1";
                }
              
            }
            if (!string.IsNullOrEmpty(Request.QueryString["typeid"]))
            {
                sql = sql + " and typeid=" + Request.QueryString["typeid"];
            }
            sql = sql + " order by proorder";

            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];

            if (table != null)
            {
                ProductBuilder(table);
            }
        }



        void ProductBuilder(DataTable table)
        {

            if (table.Rows.Count > 0)
            {
                int num8 = 0;
                foreach (DataRow row4 in table.Rows)
                {
                    System.Web.UI.HtmlControls.HtmlTableCell tdValue = new System.Web.UI.HtmlControls.HtmlTableCell();
                    tdValue.InnerHtml = row4["instruction"].ToString();
                    this.hotmsg3.Append("<td valign='top'>");
                    this.hotmsg3.Append("<div class='list'><div class='titleName'>" + row4["proname"].ToString() + "</div>");
                    this.hotmsg3.Append("<table><tr><td class='leftpic'>");
                    this.hotmsg3.Append("<a href='products_details.aspx?pid=" + row4["proid"].ToString() + "&sid=3'><img class='imgpic' src=" + System.Configuration.ConfigurationManager.AppSettings["DomainUrl"] + "/uploadfile/product/" + row4["propic2"].ToString() + "  /></a>");
                    this.hotmsg3.Append("</td></tr></table>");
                    this.hotmsg3.Append("<div class='cardprice'>");

                    this.hotmsg3.Append("零售价:" + string.Format("{0:f}", row4["proprice1"]));
                    this.hotmsg3.Append("<a href='products_details.aspx?pid=" + row4["proid"].ToString() + "&sid=3'><img class='imglook' src='images/looklook.gif'  /></a>");
                    //    this.hotmsg3 = this.hotmsg3 + "<li class='text03'>市场价:" + string.Format("{0:f}", row4["proprice3"]) + "</li>"
                    this.hotmsg3.Append("</div></div></td>");
                    num8++;
                    if (num8 >= table.Rows.Count)
                    {
                        break;
                    }
                    if ((num8 % 4) == 0)
                    {
                        this.hotmsg3.Append("</tr><tr>");
                    }
                }
            }
        }



    }
}